import Vue from 'vue'
import VueRouter from 'vue-router'
import layout from '../views/layout/index.vue'

Vue.use(VueRouter)

const routes = [
  {
    path: '/',
    redirect: '/home'
  },
  {
    path: '/login',
    name: 'login',
    component: () => import(/* webpackChunkName: "login" */ '../views/login/index.vue')
  },
  // 仪表盘
  {
    path: '/home',
    name: 'home',
    component: layout,
    meta: { title: '首页', icon: 'icon-panel', type: '2' },
    children: [
      // {
      //   path:'/home',
      //   redirect: "/home/dashboard"
      // },
      {
        path: 'dashboard',
        name: 'dashboard',
        component: () => import(/* webpackChunkName: "dashboard" */ '../views/dashboard/index.vue'),
        meta: { title: '仪表盘', type: '2' }
      },
      {
        path: 'data',
        name: 'dashboarddata',
        component: () => import(/* webpackChunkName: "dashboarddata" */ '../views/dashboard/data.vue'),
        meta: { title: '设备数据', type: '2' }
      }
    ]
  },
  // 设备网关
  {
    path: '/device',
    name: 'device',
    component: layout,
    meta: { title: '设备', icon: 'icon-luyouqi', type: '2' },
    children: [
      {
        path: 'gateway',
        name: 'gateway',
        component: () => import(/* webpackChunkName: "gateway" */ '../views/device/gateway.vue'),
        meta: { title: '网关', type: '2' }
      },
      {
        path: 'groups',
        name: 'groups',
        component: () => import(/* webpackChunkName: "groups" */ '../views/device/groups.vue'),
        meta: { title: '设备群组', type: '2' }
      },
      {
        path: 'sensorlist',
        name: 'sensorlist',
        component: () => import(/* webpackChunkName: "sensorlist" */ '../views/device/sensorlist.vue'),
        meta: { title: '传感器列表', type: '2' }
      }
    ]
  },
  // 计费
  {
    path: '/bill',
    name: 'bill',
    component: layout,
    meta: { title: '计费', icon: 'icon-fyxx', type: '2' },
    children: [
      {
        path: 'accountinfo',
        name: 'accountinfo',
        component: () => import(/* webpackChunkName: "accountinfo" */ '../views/bill/accountinfo.vue'),
        meta: { title: '账号信息', type: '2' }
      },
      {
        path: 'recharge',
        name: 'recharge',
        component: () => import(/* webpackChunkName: "groups" */ '../views/bill/recharge.vue'),
        meta: { title: '充值记录', type: '2' }
      },
      {
        path: 'use',
        name: 'use',
        component: () => import(/* webpackChunkName: "sensorlist" */ '../views/bill/use.vue'),
        meta: { title: '使用记录', type: '2' }
      }
    ]
  },
  // 测量类型
  {
    path: '/measure',
    name: 'measure',
    component: layout,
    meta: { title: '测量类型', icon: 'icon-fyxx', type: '2' },
    children: [
      {
        path: 'addmeasure',
        name: 'addmeasure',
        component: () => import(/* webpackChunkName: "accountinfo" */ '../views/measure/addmeasure.vue'),
        meta: { title: '添加测量类型', type: '2' }
      },
      {
        path: 'measurelist',
        name: 'measurelist',
        component: () => import(/* webpackChunkName: "groups" */ '../views/measure/measurelist.vue'),
        meta: { title: '测量类型列表', type: '2' }
      }
    ]
  },
  // 安全
  {
    path: '/safe',
    name: 'safe',
    component: layout,
    meta: { title: '安全', icon: 'icon-fyxx', type: '2' },
    children: [
      {
        path: 'addkey',
        name: 'addkey',
        component: () => import(/* webpackChunkName: "accountinfo" */ '../views/safe/addkey.vue'),
        meta: { title: '添加密钥', type: '2' }
      },
      {
        path: 'keylist',
        name: 'keylist',
        component: () => import(/* webpackChunkName: "groups" */ '../views/safe/keylist.vue'),
        meta: { title: '密钥列表', type: '2' }
      }
    ]
  },

  // 账号的路由和子路由
  {
    path: '/account',
    name: 'account',
    component: layout,
    meta: { title: '账号', icon: 'icon-account', type: '1' },
    children: [
      {
        path: 'add',
        name: 'add',
        component: () => import(/* webpackChunkName: "add" */ '../views/account/add.vue'),
        meta: { title: '添加账号', type: '1' }
      },
      {
        path: 'list',
        name: 'list',
        component: () => import(/* webpackChunkName: "list" */ '../views/account/list.vue'),
        meta: { title: '账号列表', type: '1' }
      }
    ]
  },

  {
    path: '*',
    name: 'page404',
    component: () => import(/* webpackChunkName: "page404" */ '../views/page404/index.vue')
  }
]

const router = new VueRouter({
  // mode: 'history',
  // base: process.env.BASE_URL,
  routes
})

export default router
